<?php
  require_once("header.inc.php");
 ?>
<!DOCTYPE html>
<html>
  <head>
    <title>Mantis Scrum Board - 1.0.0.0 - Post-Its Imprimíveis</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <style type="text/css">
      body {
        margin: 0.1cm;
      }
      
      div.postit {
        width: 7cm;
        height: 7cm;
        float: left;
        border: 3px solid black;
        margin: 0.1cm;
        font-family: Verdana, Arial, Helvetica, sans-serif;
        font-weight: bold;
        background-color: #FFFF80;
      }
      
      td.sistema {
        text-align: center;
        font-size: 20pt;  
      }
      
      td.caso {
        text-align: center;
        font-size: 50pt;
        color: blue;  
      }

      td.versao {
        text-align: left;
        padding-left: 0.3cm;
        padding-bottom: 0.3cm;
        font-size: 15pt;
        vertical-align: bottom; 
      }

      td.storypoints {
        text-align: right;
        padding-right: 0.3cm;
        padding-bottom: 0.3cm;
        font-size: 15pt;  
        vertical-align: bottom;
      }
      
      @media print {
        p.pageBreak {
          page-break-after: always;
        }
      }

      @media screen {
        p.pageBreak {
          display: none;
        }
      }
    </style>
  </head>
  <body>
<?php
  $casoPaiNumero = NULL;
    
  if (isset($_GET['cp'])) {
    $casoPaiNumero = $_GET['cp'];  
  } else {
    exit; 
  }
  
  $query = <<<EOS
SELECT BUT.ID AS caso
     , PRT.NAME AS sistema
     , COALESCE((SELECT COALESCE(CFS.VALUE,CFT.DEFAULT_VALUE) FROM mantis_custom_field_string_table CFS JOIN mantis_custom_field_table CFT ON CFT.ID = CFS.FIELD_ID WHERE CFS.FIELD_ID = %u AND CFS.BUG_ID = BUT.id),'0') AS storypoints
     , COALESCE(BUT.TARGET_VERSION,'0.0.0.0') AS versao
  FROM mantis_bug_relationship_table BRT
  JOIN mantis_bug_table BUT ON BUT.ID = BRT.DESTINATION_BUG_ID
  JOIN mantis_project_table PRT ON PRT.ID = BUT.PROJECT_ID
 WHERE BRT.RELATIONSHIP_TYPE = 2
   AND BRT.SOURCE_BUG_ID = %u
EOS;

  $casosFilhos = executarSQL(sprintf($query
                                    ,ID_CAMPO_STORYPOINT
                                    ,$casoPaiNumero));
  
  $pPP = 8;
  while ($linha = obterRegistro($casosFilhos)) {
    $sistema = acertarNomeSistema($linha->sistema,$SESS_UNIDADE->getPrefixosRemoviveis(),$SESS_UNIDADE->getAbreviaturas());
    
    $html = <<<EOH
    <div class="postit">
      <table cellspacing="0" cellpadding="0" border="0" width="100%" height="100%">
        <tr><td colspan="2" class="sistema" height="33%">$sistema</td></tr>
        <tr><td colspan="2" class="caso" height="33%">$linha->caso</td></tr>
        <tr><td width="50%" class="versao" height="33%">v$linha->versao</td><td width="50%" class="storypoints" height="33%">$linha->storypoints SP</td></tr>
      </table>
    </div>\n
EOH;
    $pPP--;
    echo($html);
    
    if ($pPP == 0) {
      $pPP = 8;
      echo("    <p class=\"pageBreak\"></p>\n");
    }
  }
?>
  </body>
</html>